home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 3.7 KB | 134 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: PRTxtBuf.h
- // Release Version: $ ODF 2 $
- // Modifed by MEB to support non-single-byte characters
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef PRTXTBUF_H
- #define PRTXTBUF_H
-
- #ifndef SLGRDEF_H
- #include "SLGrDef.h"
- #endif
-
- // ----- Foundation Layer -----
-
- #ifndef FWSTRING_H
- #include "FWString.h"
- #endif
-
- #ifndef FWEXCLIB_H
- #include "FWExcLib.h"
- #endif
-
- #ifndef SLCHARIT_H
- #include "SLCharIt.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef FWODTYPS_H
- #include "FWODTyps.h"
- #endif
-
- //========================================================================================
- // Forward class declarations
- //========================================================================================
-
- class FW_OTextRunReader;
-
- //========================================================================================
- // CLASS FW_CPrivTextBuffer
- //========================================================================================
- // Internal class used by the graphic component to read text from strings or text readers
- // for text measurement/drawing.
- // Text is sliced up into lines (terminated by newLine character)
- // We try to avoid dynamic memory allocation as possible
-
- class FW_CPrivTextBuffer
- {
- public:
- FW_DECLARE_AUTO(FW_CPrivTextBuffer)
-
- FW_CPrivTextBuffer(FW_HString string);
- // Constructs a buffer using a string as a source.
- // No data copying occurs.
-
- FW_CPrivTextBuffer(FW_HTextReader reader);
- // Constructs a buffer using a text reader as a source.
- // No data copying occurs if the first block read from the reader
- // is as large as the whole data structure;
- // otherwise, data is copied into a temporary contiguous buffer line by line.
-
- ~FW_CPrivTextBuffer();
-
- FW_Boolean IsDone() const;
- // returns TRUE when there is nothing left to read
-
- void Advance();
- // reads the next line from the buffer
-
- void GetCurrentLine(const char*& pLine, FW_ByteCount& len);
- // returns a pointer to the next contiguous line of text and its length
-
- private:
- void ResetBuffer(FW_ByteCount size = 256);
- FW_Boolean GetNextRun();
- char* FindRunNewLine();
- void AppendToBuffer(const char* pch, FW_ByteCount cb);
-
- FW_CPrivTextBuffer(const FW_CPrivTextBuffer& otherBuffer);
- FW_CPrivTextBuffer& operator=(const FW_CPrivTextBuffer& otherBuffer);
- // Copy constructor and assignment operator not valid for this class.
-
- private:
- FW_HString fString;
- FW_HTextReader fReader;
-
- char* fCurrentLine;
- FW_ByteCount fCurrentLineLength;
-
- FW_Boolean fIsDone; // are we there yet?
- FW_Boolean fIsLastLine;
-
- char* fCurRun;
- char* fCurRunPos;
- FW_ByteCount fCurRunLen;
- FW_Boolean fCurRunIsLast;
-
- enum { kBufferSize = 256 };
- char fFixedBuffer[kBufferSize];
-
- FW_Boolean fUsingFixedBuffer;
-
- char* fCurrentBufferBase;
- FW_ByteCount fCurrentBufferSize;
-
- char* fDynamicBufferBase;
- FW_ByteCount fDynamicBufferSize;
- // if the fixed buffer is too small, we allocate a dynamic buffer
- };
-
- //========================================================================================
- // Global Method FW_PrivGetStringSegment
- //========================================================================================
-
- FW_Boolean FW_PrivGetStringSegment(
- ODPlatformCanvas platformCanvas,
- FW_Boolean& bCalledBefore,
- const char* str,
- FW_ByteCount len,
- FW_BytePosition& segStart,
- FW_ByteCount& segLen,
- FW_PlatformCoordinate maxWidth,
- FW_PlatformCoordinate& actualWidth,
- FW_Boolean wordWrap,
- FW_Boolean wordBreak);
-
- #endif
-
-